#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
typedef long long LL;
int n, t;
int main()
{
	cin >> n >> t;
	int tmp = 0;
	LL ret = 0;
	for (int i = 1; i <= n; i++)
	{
		int l, r;
		cin >> l >> r;
		if (!tmp)
			tmp = r;
		else
		{
			LL sum = l - tmp - t;
			tmp = r;
			if (sum > 0)
				ret += sum;
		}
	}
	cout << ret;
	return 0;
}




